import sys
import base64
from ctypes import *

# DLL 路径（根据你的实际情况调整）
dll = cdll.LoadLibrary(r"C:\MyProject\PyProgram2\crawltx\yzm\VerificationCode.dll")

# 参数声明（推测：你可提供 HPSocket4C.dll 导出函数的话我可以补充更准确声明）
dll.Verifyingcodeinitialization.restype = c_int
dll.Verificationcoderecognition.argtypes = [c_char_p]
dll.Verificationcoderecognition.restype = c_char_p

# 初始化
dll.Verifyingcodeinitialization()

# 从主进程接收 base64 图片
b64_data = sys.stdin.read().strip()
img_bytes = base64.b64decode(b64_data)

# 写到临时文件
tmp_path = "tmp_img.png"
with open(tmp_path, "wb") as f:
    f.write(img_bytes)

# 调用 DLL 识别
res = dll.Verificationcoderecognition(tmp_path.encode("utf-8"))
print(res.decode("utf-8"))
